<template>
  <div>
    <el-tree  :load="loadNode"  :data="treeNode" lazy :props="treeProps"  @node-click="handelrNodeClick"></el-tree>
  </div>
</template>
<script>
export default {
  //初始化数据
  data() {
    return {
      treeNode: [],
      treeData: [],
      treeProps: {
        children: "children",
        label: "text"
      },
      id: "-1",
      root: ""
    };
  },
  components: {},
  //方法
  methods: {
    //请求方法
    loadNode(node, resolve) {
      this.axios
        .post(this.HOST + "/lookuptree", {
          id: node.data.id
        })
        .then(function(res) {
          resolve(res.data.data);
        })
        .catch(function(err) {
          console.log(err);
        });
    },
    //树节点点击事件
    handelrNodeClick(data){
      console.log(data);
      this.EventBus.$emit("refreshGrid",data);
    }
  },
  //页面渲染之前调用方法 函数
  created() {},
  //页面渲染完成调用方法 函数
  mounted() {}
};
</script>
